﻿namespace AbpTool.Utils
{
    public static class FolderHelper
    {
        public static void ClearFolder(string folderPath)
        {
            if (!Directory.Exists(folderPath)) return;

            // 删除所有文件
            foreach (string file in Directory.GetFiles(folderPath))
            {
                File.SetAttributes(file, FileAttributes.Normal); // 避免只读文件报错
                File.Delete(file);
            }

            // 删除所有子目录
            foreach (string subDir in Directory.GetDirectories(folderPath))
            {
                // 递归删除整个子目录
                Directory.Delete(subDir, recursive: true);
            }

            Console.WriteLine($"已清空文件夹: {folderPath}");
        }
    }
}
